<?
	$pj00 = "x";
	/* Incluimos otros scripts (adicionales) */
	require('load.php');
	/* Incluimos: objetos necesarios (jugador, enemigos, etc) */
	require('objects/characters/'.$pj00.'.php'); // Personaje
?>

var sc00, rb00, pj_x, pj_rockman;

$(document).ready(function () {
	window.history.forward();
	rb00 = "images/general/joystick.png";
	sc00 = "images/interface/map/net/sc00.gif";
	pj_x = "images/character/play/x.png";
	pj_rockman = "images/character/play/rockman.png";
	comprobar();
});

function comprobar() {
	cargar = new Array(
		rb00, sc00, pj_x, pj_rockman
	)
	iniciar();
}

function construir() {
	/* I - Joystick */
	$("#yt01").css("background-image","url(" + rb00 + ")");
	$("#yt02").css("background-image","url(" + rb00 + ")");
	$("#yt03").css("background-image","url(" + rb00 + ")");
	$("#yt04").css("background-image","url(" + rb00 + ")");
	$("#yt05").css("background-image","url(" + rb00 + ")");
	$("#yt06").css("background-image","url(" + rb00 + ")");
	$("#yt07").css("background-image","url(" + rb00 + ")");
	/* F - Joystick */
	$("#sc00").css("background-image","url(" + sc00 + ")");
	player();
}

var flag0x001 = 0;

var pj00 = new<?php echo ucfirst($pj00); ?>(atributos_<?php echo ucfirst($pj00); ?>);
// Instancia Helper (Evitar Bug's) 
var helper = new<?php echo ucfirst($pj00); ?>(atributos_<?php echo ucfirst($pj00); ?>);

function player() {
	pj00.instanciar("00", 0, 0, 15);
	pj00.stay("00");
	helper.instanciar("01", 0, 0, 15);
	helper.stay("01");
	/* I - Teclado y Joystick */
	$(document).keydown(function(event) { ejecutarbtn(event.which); });
	$(document).keyup(function(event) { soltarbtn(event.which); });
	/* F - Teclado y Joystick */
}

/* Flags
 * =====
 * 0x001 -> 0: Boton presionado, 1: Boton soltado
 */

var flag0x001 = 0;

function ejecutarbtn(btn) {
	if(flag0x000 == 1) {
		switch(btn) {
			case 13: // Enter 	(S)
			case 90: // Z		(A)
			case 39: // >		(>)
				flag0x001 = 1;
				if(flag0x001 == 1)
					pj00.caminar_derecha();
				break;
			case 37: // <		(<)
				flag0x001 = 1;
				if(flag0x001 == 1)
					pj00.caminar_izquierda();
				break;
		}
	}
}

function soltarbtn(btn) {
	if(flag0x000 == 1) {
		switch(btn) {
			case 13: // Enter 	(S)
			case 90: // Z		(A)
			case 39: // >		(>)
				flag0x001 = 0;
				if(flag0x001 == 0)
					pj00.stay();
				break;
			case 37: // <		(<)
				flag0x001 = 0;
				if(flag0x001 == 0)
					pj00.stay();
				break;
		}
	}
}